﻿<Window x:Class="LockCrypt.WinTemplates"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lex="http://schemas.root-project.org/xaml/presentation"
    xmlns:l49ui="clr-namespace:Lime49.UI;assembly=Lime49"
    xmlns:l49="clr-namespace:Lime49;assembly=Lime49"
    Title="{lex:LocText LockCrypt.Core:Strings:Templates}" Style="{StaticResource {x:Type Window}}" Icon="/LockCrypt;component/Resources/LockCrypt.ico"
    MinHeight="250" MinWidth="100" Width="400" Height="360"
    WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" x:Name="root"
    l49:WindowService.EscapeClosesWindow="True">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Delete" Executed="DeleteTemplate" CanExecute="IsItemSelected"/>
        <CommandBinding Command="ApplicationCommands.Help" Executed="ShowHelp" CanExecute="CanAlwaysExecute"/>
        <CommandBinding Command="ApplicationCommands.New" Executed="AddTemplate" CanExecute="CanAlwaysExecute"/>
        <CommandBinding Command="ApplicationCommands.Properties" Executed="EditTemplate" CanExecute="IsItemSelected"/>
        <CommandBinding Command="NavigationCommands.Refresh" Executed="LoadTemplates" CanExecute="IsWorkerBusy"/>
    </Window.CommandBindings>
    <Window.Resources>
        <Image x:Key="edit_16" x:Shared="False" Source="pack://application:,,,/Resources/images/edit_16.png"/>
        <Image x:Key="delete_16" x:Shared="False" Source="pack://application:,,,/Resources/images/delete_16.png"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <DockPanel DockPanel.Dock="Top" LastChildFill="True" HorizontalAlignment="Stretch" Width="Auto">
            <ToolBar DockPanel.Dock="Right" BorderThickness="0,0,1,1">
                <l49ui:ImageButton Command="ApplicationCommands.Help" Text="{lex:LocText LockCrypt.Core:Strings:Help}" Image="pack://application:,,,/Resources/Images/question_24.png" ShowText="False" ToolTip="{lex:LocText LockCrypt.Core:Strings:LockCryptHelp}"
                                 Style="{StaticResource ToolBarButton}" />
            </ToolBar>
            <ToolBar DockPanel.Dock="Left" BorderThickness="1,0,0,1">
                <l49ui:ImageButton HorizontalAlignment="Stretch" Command="ApplicationCommands.New" Text="{lex:LocText LockCrypt.Core:Strings:NewTemplate}" ToolTip="{lex:LocText LockCrypt.Core:Strings:NewTemplate}" ShowText="False" Image="pack://application:,,,/Resources/Images/add_24.png"
                                 CommandParameter="{Binding ElementName=lstTemplates,Path=SelectedItem}" Style="{StaticResource ToolBarButton}" />
                <l49ui:ImageButton HorizontalAlignment="Stretch" Command="ApplicationCommands.Properties" Text="{lex:LocText LockCrypt.Core:Strings:Edit}" ToolTip="{lex:LocText LockCrypt.Core:Strings:Edit}" ShowText="False" Image="pack://application:,,,/Resources/Images/edit_24.png"
                                 CommandParameter="{Binding ElementName=lstTemplates,Path=SelectedItem}" Style="{StaticResource ToolBarButton}" />
                <l49ui:ImageButton HorizontalAlignment="Stretch" Command="ApplicationCommands.Delete" Text="{lex:LocText LockCrypt.Core:Strings:Delete}" ToolTip="{lex:LocText LockCrypt.Core:Strings:Delete}" ShowText="False" Image="pack://application:,,,/Resources/Images/delete_24.png"
                                     CommandParameter="{Binding ElementName=lstTemplates,Path=SelectedItem}" Style="{StaticResource ToolBarButton}" />
            </ToolBar>
        </DockPanel>
            
        <ListBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" x:Name="lstTemplates" Margin="6" DisplayMemberPath="{Binding Name}">
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <EventSetter Event="MouseDoubleClick" Handler="lst_MouseDoubleClick"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Edit}" Command="ApplicationCommands.Properties" Icon="{StaticResource edit_16}"
                              CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Delete}" Command="ApplicationCommands.Delete" Icon="{StaticResource delete_16}" 
                              CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
        <StatusBar Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" MinHeight="24">
            <DockPanel LastChildFill="True">
                <TextBlock x:Name="lblRecordCount" DockPanel.Dock="Left" Visibility="Collapsed" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
                <TextBlock x:Name="lblStatus" DockPanel.Dock="Left" Visibility="Hidden" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
                <ProgressBar x:Name="prgStatus" DockPanel.Dock="Right" IsIndeterminate="True" MinWidth="40" Visibility="Hidden" />
            </DockPanel>
        </StatusBar>
    </Grid>
</Window>
